package com.itic.appbase.framework.utils;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.ParseException;
import net.sf.json.JSONObject;

public class AuthTest {

	public static void main(String[] args) throws ParseException, UnsupportedEncodingException, IOException {
		
		//JSONObject params = new JSONObject();

		Map<String, Object> params = new HashMap<>();
		
		params.put("appkey", "68943923115886070418838901844741");
		params.put("sign_key", "lezitiancheng");
		params.put("auth_code", "yA7b3q04EUssKGisMBQRr6x2NmFG5OQa");
		params.put("api_link", "http://ca.mygjp.com:8010/api");
		params.put("companyName", "TestMall");
		params.put("userName", "test");
		params.put("userpass", "grasp@101 ");
		params.put("app_secret", "ONxYDyNaCoyTzsp83JoQ3YYuMPHxk3j7 ");
		params.put("redirect_url", "");
		params.put("get_auth_code_url", "http://ca.mygjp.com:8012/account/login?appkey=68943923115886070418838901844741&redirect_url=&keyword=test");
		
		
		StringBuffer sb = new StringBuffer("http://ca.mygjp.com:8010/api/token?");
		for(String key :params.keySet())
			sb.append(key).append("=").append(params.get(key)).append("&");
		Map<String, Object> tokenParams = new HashMap<>();
		tokenParams.put("appkey", "68943923115886070418838901844741");
		tokenParams.put("p", "68943923115886070418838901844741");
		
		tokenParams.put("sign", "68943923115886070418838901844741");
		System.out.println(sb.toString());
		
		JSONObject obj = HttpRequestUtils.httpGetJSONObject(sb.toString());
		System.out.println(obj.toString());
	}

	
	
	
}
